<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">
        <h:form>
            <p:panel>
                <f:facet name="header">
                    <p:outputLabel value="Select Request For Department : #{sessionController.department.name}"/>    
                </f:facet> 
                <h:panelGrid columns="2" >
                    <h:outputLabel value="From Date"/>
                    <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{searchController.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >      
                    </p:calendar>
                    <h:outputLabel value="To Date"/>
                    <p:calendar id="toDate" value="#{searchController.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >                                                                              
                    </p:calendar>
                    <h:outputLabel value="Staff "/>                           
                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.staffName}" />

                    <h:outputLabel  value="From Department"  ></h:outputLabel>
                    <p:autoComplete  value="#{searchController.searchKeyword.frmDepartment}"  
                                     completeMethod="#{departmentController.completeDept}" var="dept1"
                                     itemValue="#{dept1}" itemLabel="#{dept1.name}" 
                                     forceSelection="true" rendered="true">
                    </p:autoComplete>

                    <h:outputLabel  value="To Department"  ></h:outputLabel>
                    <p:autoComplete  value="#{searchController.searchKeyword.tooDepartment}"  
                                     completeMethod="#{departmentController.completeDept}" var="dept"
                                     itemValue="#{dept}" itemLabel="#{dept.name}" 
                                     forceSelection="true" rendered="true">
                    </p:autoComplete>
                </h:panelGrid>
                <h:panelGrid columns="4">
                    <p:spacer width="115" height="1"/>
                    <p:commandButton id="btnSearch" ajax="false" value="Search" action="#{searchController.createIssueStoreReport()}"/>
                    <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" style="float: right;" >
                        <p:printer target="datatable"  />
                    </p:commandButton>

                    <p:commandButton actionListener="#{searchController.createIssueStoreReport()}" ajax="false" value="Excel" styleClass="noPrintButton" >
                        <pe:exporter type="xlsx" target="tbl1" fileName="Pharmacy_Transfer_Issued_List_Report"  />
                    </p:commandButton>
                </h:panelGrid>




                <p:panel id="datatable">
                    <p:dataTable id="tbl1" value="#{searchController.bills}" var="p"> 
                        <f:facet name="header">
                            <h:outputLabel value="Transfer Issue Not Recieved &emsp; From :"/>
                            <h:outputLabel value="#{searchController.searchKeyword.frmDepartment.name}"/> 
                            <h:outputLabel value=" &emsp; To :"/>
                            <h:outputLabel value="#{searchController.searchKeyword.tooDepartment.name}"/> 
                            <h:outputLabel value="From : " style=" white-space:pre-line;"/>
                            <h:outputLabel  value="#{searchController.fromDate}" >
                                <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a"/>
                            </h:outputLabel>
                            <h:outputLabel value="&emsp;&emsp;To :"/>
                            <h:outputLabel  value="#{searchController.toDate}" >
                                <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a"/>
                            </h:outputLabel>
                        </f:facet>

                        <p:column headerText="Issue No">                        
                            <h:outputLabel value="#{p.deptId}"/>                          
                        </p:column>

                        <p:column headerText="From Department">                       
                            <h:outputLabel value="#{p.department.name}"/>                          
                        </p:column>

                        <p:column headerText="To Department">                       
                            <h:outputLabel value="#{p.toDepartment.name}"/>                          
                        </p:column>

                        <p:column headerText="Billed At">                       
                            <h:outputLabel value="#{p.createdAt}"/>                          
                        </p:column>

                        <p:column headerText="Billed By">                       
                            <h:outputLabel value="#{p.creater.staff.person.nameWithTitle}"/>                          
                        </p:column>

                        <p:column headerText="Transporter">                       
                            <h:outputLabel value="#{p.toStaff.person.nameWithTitle}"/>                          
                        </p:column>

                        <p:column headerText="Value">                       
                            <h:outputLabel value="#{p.netTotal}"/>
                            <f:facet name="footer">
                                <h:outputLabel value="#{searchController.netTotalValue}"/>
                            </f:facet>
                        </p:column>
                                <f:facet name="footer" >
                                    <h:outputLabel value="Printed By : #{sessionController.loggedUser.webUserPerson.name}" style="float: right"/>
                                </f:facet>

                        <!--                    <p:column headerText="Received">                   
                                                <p:dataTable var="b" value="#{p.forwardReferenceBills}">                           
                                                    <p:column  >                                                               
                                                        <h:outputLabel  value="#{b.deptId}"/>                                   
                                                    </p:column>
                                                </p:dataTable>
                                            </p:column>-->

                    </p:dataTable>
                </p:panel>

            </p:panel>
        </h:form>
    </ui:define>  

</ui:composition>
